#!/usr/bin/python
# -*- coding: utf-8 -*-

import multiprocessing
import time
import sys


def myprint(obj):
    sys.stdout.write(str(obj) + '\n')


def daemon():
    myprint(' '.join(('Starting:',
            multiprocessing.current_process().name)))
    time.sleep(2)
    myprint(' '.join(('Exiting :',
            multiprocessing.current_process().name)))


def non_daemon():
    myprint(' '.join(('Starting:',
            multiprocessing.current_process().name)))
    myprint(' '.join(('Exiting :',
            multiprocessing.current_process().name)))


if __name__ == '__main__':
    d = multiprocessing.Process(name='daemon', target=daemon)
    d.daemon = True

    n = multiprocessing.Process(name='non-daemon', target=non_daemon)
    n.daemon = False

    d.start()
    time.sleep(1)
    n.start()

    d.join()
    n.join()
